/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.*;
import java.util.*;
import java.sql.*;

public class EnrAccountFormBean {

    public String select;
    public String enr;
    public String custid;
    public Hashtable errors;
    public DbConnect dbc;

    public String getErrorMsg(String s) {
        String errorMsg = (String) errors.get(s.trim());
        return (errorMsg == null) ? "" : errorMsg;
    }

    public EnrAccountFormBean() {
        select = "";
        enr = "";
    }

    public void setSelect(String a) {
        select = a;
    }

    public void setEnr(String a) {
        enr = a;
    }

    public boolean updates() {

        boolean flag = false;
        Connection con = null;
        dbc = new DbConnect();
        System.out.println(enr + select);
       System.out.println(custid);
        try {

            con = dbc.getOracleConnection();
            Statement st = con.createStatement();
            if (enr.equals("enroll")) {
                st.executeUpdate("update onbill_billstatus set billstatus=1 where billpayid=(select billpayid from onbill_account where accno=" + select + ")");
                st.executeUpdate("commit");
            }
            if (enr.equals("unenroll")) {
                st.executeUpdate("update onbill_billstatus set billstatus=0 where billpayid=(select billpayid from onbill_account where accno=" + select + ")");
                st.executeUpdate("commit");
            }
            flag = true;


        } catch (Exception e) {
            e.printStackTrace();
        }

        return flag;
    }
}
